package com.nuaa.yygh.hosp.controller;


import com.nuaa.model.hosp.Hospital;
import com.nuaa.vo.hosp.HospitalQueryVo;
import com.nuaa.yygh.common.result.Result;
import com.nuaa.yygh.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

//用于管理医院前端网站上的医院信息
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")

public class HospitalController {
    //注入医院的service，方便调用
    @Autowired
    private HospitalService hospitalService;

    //1.获取分页列表
    @ApiOperation(value = "1.获取分页列表")
    @GetMapping("list/{page}/{limit}")
    public Result getHospList(@ApiParam(name = "page",value = "当前页码",required = true)
                        @PathVariable Integer page,
                        @ApiParam(name = "limit",value = "每页记录数",required = true)
                        @PathVariable Integer limit,
                        @ApiParam(name = "hospitalQueryVo",value = "对象",required = false)
                                    HospitalQueryVo hospitalQueryVo
                        ){
        Page<Hospital> pageModel = hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(pageModel);
    }

    //2.根据id更新医院的上线状态
    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result lock(@PathVariable("id") String id,
                       @PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    //3.获取医院详情
    @ApiOperation(value = "获取医院详情")
    @GetMapping("show/{id}")
    public Result showHosp(@PathVariable String id){
        Map<String, Object> map = hospitalService.show(id);
        return Result.ok(map);
    }


}
